package com.tuju.jetpackfirstdemo.ui.list

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.ArrayAdapter
import com.tuju.jetpackfirstdemo.R
import kotlinx.android.synthetic.main.activity_list.*
import java.util.ArrayList
import java.util.HashMap

class ListActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_list)

        lv_contactsList.adapter = ArrayAdapter(this, android.R.layout.simple_expandable_list_item_1, getData())
        val letterMap = HashMap<String, Int>()
        letterMap["A"] = 0
        letterMap["B"] = 3
        letterMap["C"] = 7
        letterMap["F"] = 10
        letterMap["I"] = 13
        letterMap["K"] = 16
        letterMap["L"] = 19
        letterMap["M"] = 20
        letterMap["N"] = 22
        letterMap["S"] = 23
        letterMap["T"] = 25
        letterMap["X"] = 28
        IndexControl(lv_contactsList, liv_letters, tv_hint, letterMap)
    }

    private fun getData(): List<String> {
        val data = ArrayList<String>()
        data.add("abc")
        data.add("aabc")
        data.add("aabc")
        data.add("babc")
        data.add("b")
        data.add("bc")
        data.add("babc")
        data.add("cabc")
        data.add("cabc")
        data.add("cabc")
        data.add("fabc")
        data.add("fabc")
        data.add("fabc")
        data.add("iabc")
        data.add("i")
        data.add("ic")
        data.add("kabc")
        data.add("kabc")
        data.add("kabc")
        data.add("leavesC")
        data.add("mabc")
        data.add("mabc")
        data.add("nabc")
        data.add("sabc")
        data.add("sabc")
        data.add("tabc")
        data.add("tabc")
        data.add("tabc")
        data.add("xabc")
        data.add("xabc")
        data.add("xabc")
        return data
    }

}
